﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace XYX.Http.Host
{
    /// <summary>
    /// IOC容器
    /// </summary>
    public class Container : IContainer
    {
        /// <summary>
        /// 容器
        /// </summary>
        private Dictionary<Type, Resolver> dicContainer = new Dictionary<Type, Resolver>();

        /// <summary>
        /// 构造
        /// </summary>
        /// <param name="dicContainer"></param>
        public Container(Dictionary<Type, Resolver> dicContainer)
        {
            this.dicContainer = dicContainer;
        }
        /// <summary>
        /// 获取实例
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public T Resolve<T>() where T : class
        {
            return (T)dicContainer[typeof(T)].GetHandlerInstance();
        }
    }
}
